import { computed, inject } from 'vue'
import type baTableClass from '/@/utils/baTable'
import { auth } from '/@/utils/common'

//售后单状态
export enum refundStatus {
    auditing = 1,
    complete = 2,
    cancel = 3,
}

//售后审核状态
export enum auditStatus {
    wait_audit = 1,
    agree = 2,
    refuse = 3,
}
//用户发货状态
export enum userShipStatus {
    not_shipped = 0,
    shipped = 1,
}
//商家收货状态
export enum receiveStatus {
    not_receive = 0,
    received = 1,
}

//售后类型tag
export const refundTypeTagType = (type: number) => {
    switch (type) {
        case 1:
            return 'danger'
        case 2:
            return 'primary'
    }
}

// 售后状态tag
export const statusTagType = (status: number) => {
    switch (status) {
        case 1:
            return 'warning'
        case 2:
            return 'success'
        case 3:
            return 'danger'
        default:
            return 'info'
    }
}

// 商家审核状态tag
export const auditStatusTagType = (status: number) => {
    switch (status) {
        case 1:
            return 'warning'
        case 2:
            return 'success'
        case 3:
            return 'danger'
        default:
            return 'info'
    }
}

// 用户发货审核状态tag
export const userShipStatusTagType = (status: number) => {
    switch (status) {
        case 1:
            return 'success'
        default:
            return 'info'
    }
}

// 商家收货审核状态tag
export const receiveStatusTagType = (status: number) => {
    switch (status) {
        case 1:
            return 'success'
        default:
            return 'info'
    }
}

// 审核按钮
export const showAuditBtn = (row: TableRow) => {
    return row.audit_status === auditStatus.wait_audit && auth({ name: '/admin/shop/order/refund', subNodeName: '/admin/shop/order/refund/audit' })
}

// 确认收货按钮
export const showReceiveBtn = (row: TableRow) => {
    return (
        row.status === refundStatus.auditing &&
        row.user_ship_status === userShipStatus.shipped &&
        auth({ name: '/admin/shop/order/refund', subNodeName: '/admin/shop/order/refund/receive' })
    )
}
